﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;

namespace Bussiness_Objects
{
    /// <summary>
    /// Thong tin table CT_PHIEUNHAPSACH
    /// --CT_PHIEUNHAPSACH(SoPNS,MaSach,SoLuongNhap,DonGia,ThanhTien)
    /// </summary>
    public class CTPhieuNhapSach : BusinessObjects
    {
        public CTPhieuNhapSach()
        {
            SoPNS = Int16.MaxValue;
            MaSach = Int16.MaxValue;
            SoLuongNhap = Int16.MaxValue;
            ThanhTien = long.MaxValue;
        }

        public CTPhieuNhapSach(int _soPns, int _maSach, int _soLuog, long _donGia, long _thanhTien)
        {
            SoPNS = _soPns;
            MaSach = _maSach;
            SoLuongNhap = _soLuog;
            DonGia = _donGia;
            ThanhTien = _thanhTien;
        }

        public override void SetParameterInsert()
        {
            parms = new object[4];           

            SqlParameter _parm = new SqlParameter(parMaSach, MaSach);
            parms[0] = _parm;

            _parm = new SqlParameter(parSoLuongNhap, SoLuongNhap);
            parms[1] = _parm;

            _parm = new SqlParameter(parSoPNS, SoPNS);
            parms[2] = _parm;

            _parm = new SqlParameter(parDonGia, DonGia);
            parms[3] = _parm;
        }

        public void SetDataUpdate(int _maSach, int _soPNS)
        {
            MaSach_new = _maSach;
            SoPNS_new = _soPNS;
        }

        public override void SetParameterUpdate()
        {
            parms = new object[7];
            SqlParameter _parm = new SqlParameter(parThanhTien, ThanhTien);
            parms[0] = _parm;

            _parm = new SqlParameter(parMaSach + "_old", MaSach);
            parms[1] = _parm;

            _parm = new SqlParameter(parMaSach + "_new", MaSach_new);
            parms[2] = _parm;

            _parm = new SqlParameter(parSoLuongNhap, SoLuongNhap);
            parms[3] = _parm;

            _parm = new SqlParameter(parSoPNS + "_old", SoPNS);
            parms[4] = _parm;

            _parm = new SqlParameter(parSoPNS + "_new", SoPNS_new);
            parms[5] = _parm;

            _parm = new SqlParameter(parDonGia, DonGia);
            parms[6] = _parm;
        }

        public void SetParameterDelete()
        {
            parms = new object[2];
            SqlParameter _parm = new SqlParameter(parSoPNS, SoPNS);
            parms[0] = _parm;

            _parm = new SqlParameter(parMaSach, MaSach);
            parms[1] = _parm;
        }

        public int SoPNS { get; set; }
        private const string parSoPNS = "@SoPNS";

        public int SoPNS_new { get; set; }        

        public int MaSach { get; set; }
        private const string parMaSach = "@MaSach";

        public int MaSach_new { get; set; }

        public int SoLuongNhap { get; set; }
        private const string parSoLuongNhap = "@SoLuongNhap";

        public long DonGia { get; set; }
        private const string parDonGia = "@DonGia";
        
        public long ThanhTien { get; set; }
        private const string parThanhTien = "@ThanhTien";
    }
}
